package com.it.controller;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert;
import com.it.dto.OAuth2ClientDTO;
import com.it.pojo.entity.SysOauthClient;
import com.it.result.R;
import com.it.service.ISysOauthClientService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api/oauth-clients")
@Slf4j
@RequiredArgsConstructor
@RestController
public class OauthClientController {
   private final ISysOauthClientService iSysOauthClientService;
   @GetMapping("/getOAuth2ClientById")
   public R<OAuth2ClientDTO> getOAuth2ClientById(@RequestParam String clientId)
   {
       SysOauthClient client = iSysOauthClientService.getById(clientId);
       Assert.notNull(client, "OAuth2 客户端不存在");
       OAuth2ClientDTO oAuth2ClientDTO = new OAuth2ClientDTO();
       BeanUtil.copyProperties(client, oAuth2ClientDTO);
       return R.ok(oAuth2ClientDTO);
   }
}